#include<bits/stdc++.h>
using namespace std;

struct node{
    int l,r;
}ll[100005];
int d[100005],vv[100005],a[100005],p[100005],k;

inline int shunshichesu(int s,int v,int a,int V){
    if(s<0)return 0;
    double x=sqrt(v*v+2*a*s);
    if(x>V)return 1;
    return 0;
}

inline bool cmp(node x,node y){
    if(x.r==y.r)return x.l<y.l;
    return x.r<y.r;
}

int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int T,n,m,l,v,ans1,ans2,mid,q;
    int zuo,you;
    scanf("%d",&T);
    for(int kkk=0;kkk<T;++kkk){
        scanf("%d%d%d%d",&n,&m,&l,&v);
        k=ans1=ans2=0;
        for(int i=1;i<=n;++i)scanf("%d%d%d",&d[i],&vv[i],&a[i]);
        for(int j=1;j<=m;++j)scanf("%d",&p[j]);
        for(int i=1;i<=n;++i){
            if(a[i]==0){
                if(vv[i]>v){
                    ans1++;
                    if(p[m]<d[i]){
                        ans1--;
                        continue;
                    }
                    ll[++k].l=lower_bound(p+1,p+1+m,d[i])-p;
                    ll[k].r=m;
                }
            }
            if(a[i]>0){
                if(shunshichesu(p[m]-d[i],vv[i],a[i],v)){
                    ans1++;
                    zuo=lower_bound(p+1,p+1+m,d[i])-p;
                    you=m;
                    while(zuo<=you){
                        mid=(zuo+you)>>1;
                        if(shunshichesu(p[mid]-d[i],vv[i],a[i],v))you=mid-1;
                        else zuo=mid+1;
                    }
                    ll[++k].l=mid;
                    ll[++k].r=m;
                }
            }
            if(a[i]<0){
                if(vv[i]>v){
                    q=lower_bound(p+1,p+1+m,d[i])-p;
                    if(q>m)continue;
                    zuo=q;
                    if(!shunshichesu(p[zuo]-d[i],vv[i],a[i],v))continue;
                    ans1++;
                    if(zuo==m){
                        ll[++k].l=m;
                        ll[k].r=m;
                        continue;
                    }
                    int vf=vv[i]*vv[i],c=(-a[i])*2;
                    int lucheng=(vf/c);
                    int zd=min(d[i]+lucheng,l);
                    you=lower_bound(p+1,p+1+m,zd)-p;
                    if(you>m)you=m;
                    ll[++k].l=zuo;
                    while(zuo<=you){
                        mid=(zuo+you)>>1;
                        if(shunshichesu(p[mid]-d[i],vv[i],a[i],v))zuo=mid+1;
                        else you=mid-1;
                    }
                    ll[k].r=mid;
                }

            }
        }
        sort(ll+1,ll+1+k,cmp);
        if(ans1>0){
        int rr=ll[1].r;
        for(int i=2;i<=k;++i){
            if(ll[i].l<=rr)continue;
            else{
                rr=ll[i].r;
                ans2++;
            }
        }
        if(ans2==0)ans2++;
        printf("%d %d\n",ans1,m-ans2);
        }
        else printf("%d %d\n",0,m);
    }
    return 0;
}
